/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa165.carpark.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Viktor Borza
 */
@Entity
public class ServiceCheck implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name="service_check_id")
    private Long id;
    
    @Temporal(TemporalType.DATE)
    @Column(name = "Date_Of_Check")
    private Date dateOfCheck;
    
    /*
     * Last serviceChek km
     */
    @Column(name = "Last_Check_Distance",nullable=false)
    @Min(-1)
    private int lastCheck = -1;
    
    /*
     * Interval
     */
    @Column(name = "Check_Interval",nullable=false)
    @Min(0)
    private int checkInterval;
    
    /*
     * Purpose of check
     */
    @Column(name = "Check_Purpose",length = 50,nullable=false)
    @Size(min=3,max=50)
    private String checkPurpose; 
    
    /*
     *  Is ServiceCheck done allready?
     */
    @Column(name = "Check_Done")
    private boolean checkDone = false;
    
    @Column(name = "is_active")
    @NotNull
    private boolean isActive = false;

    public boolean isCheckDone() {
        return checkDone;
    }

    public boolean isIsActive() {
        return isActive;
    }

    public void setIsActive(boolean isActive) {
        this.isActive = isActive;
    }


    public void setCheckDone(boolean checkDone) {
        this.checkDone = checkDone;
    }

    public Long getId() {
        return id;
    }

    public Date getDateOfCheck() {
        return dateOfCheck;
    }

    public void setDateOfCheck(Date dateOfCheck) {
        this.dateOfCheck = dateOfCheck;
    }

//    public int getDistanceToNextCheck() {
//        return lastCheck + checkInterval;
//    }

    public int getLastCheck() {
        return lastCheck;
    }

    public void setLastCheck(int lastCheck) {
        this.lastCheck = lastCheck;
    }

    public String getCheckPurpose() {
        return checkPurpose;
    }

    public void setCheckPurpose(String checkPurpose) {        
        this.checkPurpose = checkPurpose;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    public int getCheckInterval() {
        return checkInterval;
    }

    public void setCheckInterval(int checkInterval) {
        this.checkInterval = checkInterval;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof ServiceCheck)) {
            return false;
        }
        ServiceCheck other = (ServiceCheck) object;
        if ((this.id != null && !this.id.equals(other.id)) || (this.id == null && other.id != null)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ServiceCheck{" + "id=" + id + ", dateOfCheck=" + dateOfCheck + ", lastNextCheck=" + lastCheck + ", checkReport=" + checkPurpose + ", checkDone=" + checkDone + ", isActive=" + isActive + '}';
    }

    
    
}
